package com.jiangnan.constants;

import javax.swing.*;
import java.net.URL;

/**
 * 顶部的按钮
 *
 * @author chenliang
 * @email wschenliang@aliyun.com
 */
public class TopButton {
    public static TopButton
            START = new TopButton("开始", "开始", TopButton.class.getResource("/image/wireshark_start.png")),
            STOP = new TopButton("停止", "停止", TopButton.class.getResource("/image/wireshark_stop.png")),
            SAVE = new TopButton("保存文件", "保存文件", TopButton.class.getResource("/image/wireshark_save.png")),
            SAVE_AS_JSON = new TopButton("保存JSON", "JSON", TopButton.class.getResource("/image/json.png")),
            OPEN = new TopButton("打开文件","打开文件",  TopButton.class.getResource("/image/wireshark_open.png")),
            FILE_APPEND = new TopButton("追加文件","追加文件",  TopButton.class.getResource("/image/file_append.png")),
            OPTIONS = new TopButton("设置", "设置", TopButton.class.getResource("/image/wireshark_options.png")),
            CLOSE = new TopButton("清除", "清除", TopButton.class.getResource("/image/wireshark_close.png")),
            RESTART = new TopButton("重启", "重启", TopButton.class.getResource("/image/wireshark_restart.png")),
            RESORT = new TopButton("重新排序", "重新排序", TopButton.class.getResource("/image/resort.png"));


    private String tipText;//按钮的提示文字
    private String text;//按钮填充文字
    private URL iconUrl;//按钮图片链接

    TopButton(String tipText, String text, URL iconUrl) {
        this.tipText = tipText;
        this.text = text;
        this.iconUrl = iconUrl;
    }

    public String getTipText() {
        return tipText;
    }

    public void setTipText(String tipText) {
        this.tipText = tipText;
    }

    public URL getIconUrl() {
        return iconUrl;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Icon getIcon() {
        if (iconUrl == null) {
            return null;
        }
        return new ImageIcon(iconUrl);
    }

    public void setIconUrl(URL iconUrl) {
        this.iconUrl = iconUrl;
    }
}
